package design.mode.strategy.item1;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 策略类是有状态的，根据业务场景的需要，我们希望每次从工厂方法中
 */
public class StrategyFactory2 {
    public static Strategy getStrategy(String type) {
        if (type == null || type.isEmpty()) {
            throw new IllegalArgumentException("");
        }
        if (type.equals("A")) {
            return new ConcreteStrategyA();
        } else if (type.equals("B")) {
            return new ConCreteStrategyB();
        }
        return null;
    }

    public static void main(String[] args) {
        List<String> strings = new ArrayList<>();
        strings.add("1");
        strings.add("2");
        strings.add("3");
        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()){
            iterator.next();
            iterator.remove();
            iterator.remove();
        }
    }
}
